cmake_minimum_required(VERSION 3.14)
project(NCNN_YOLO_Inferrer)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置 ncnn 和 OpenCV 的安装路径（请根据你的实际路径修改）
set(NCNN_DIR "/home/kidecr/git-store/ncnn/build/install")       # 替换为你自己的 ncnn 安装路径
# set(OpenCV_DIR "/usr/local/opencv")      # 或者你自定义的 OpenCV 路径

# 包含头文件路径
include_directories(
    ${PROJECT_SOURCE_DIR}
    ${NCNN_DIR}/include
)

# 链接库搜索路径
link_directories(
    ${NCNN_DIR}/lib
)

# 查找 OpenCV
find_package(OpenCV REQUIRED)
if(OpenCV_FOUND)
    include_directories(${OpenCV_INCLUDE_DIRS})
endif()

# 查找 OpenMP
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

# 添加源文件
file(GLOB SOURCES "*.cpp")
add_executable(${PROJECT_NAME} ${SOURCES})

# 链接库
target_link_libraries(${PROJECT_NAME}
    PRIVATE
    ncnn glslang
    ${OpenCV_LIBS}
)

# 如果启用 Vulkan，添加链接选项（视平台而定）
if(APPLE)
    target_link_libraries(${PROJECT_NAME} PRIVATE -framework Metal -framework QuartzCore)
elseif(UNIX AND NOT APPLE)
    target_link_libraries(${PROJECT_NAME} PRIVATE -lvulkan)
endif()